﻿using System;
using System.Text;
using TI_BLE_HCI_ClientLib.BaseEntities;
using TI_BLE_HCI_ClientLib.GenericHCIEntities;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;

namespace TI_BLE_HCI_ClientLib.HCICommands
{
    public class HCICommand_GATT_Add_Attribute : HCIVendorSpecificCommand
    {
        private const byte CMD = 0xFE;

        [Flags]
        public enum PermissionsEnum
        {
            GATT_PERMIT_NONE=0x0,
            GATT_PERMIT_READ=0x01,
            GATT_PERMIT_WRITE = 0x02,
            GATT_PERMIT_AUTHEN_READ = 0x04,
            GATT_PERMIT_AUTHEN_WRITE = 0x08,
            GATT_PERMIT_AUTHOR_READ = 0x10,
            GATT_PERMIT_AUTHOR_WRITE = 0x20
        }

        public HCICommand_GATT_Add_Attribute(ushort uuid, PermissionsEnum permissions)
            : base(HCIVendorSpecificCommandCSG.ATT,CMD)
        {
            var pars = new BaseEntityParameter[2];

            pars[0] = new WordParameter(uuid);
            pars[1] = new ByteParameter((byte)permissions);
            
            base.addParameters(pars);
        }

        public HCICommand_GATT_Add_Attribute(byte[] uuid, PermissionsEnum permissions)
            : base(HCIVendorSpecificCommandCSG.ATT, CMD)
        {
            var pars = new BaseEntityParameter[2];

            pars[0] = new ByteArrayParameter(uuid);
            pars[1] = new ByteParameter((byte)permissions);

            base.addParameters(pars);
        }

    }
}
